//
//  ZHStatisticsThreeCollectionViewCell.m
//  Doctor
//
//  Created by liuzhishan on 15/12/24.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHStatisticsThreeCollectionViewCell.h"
#import "ZHClinicAllData.h"
#import "DataTool.h"
#define  ALLHEIGHT  250

@interface ZHStatisticsThreeCollectionViewCell ()

@property (nonatomic,strong) UIView* leftView;
@property (nonatomic,strong) UIView* centerView;
@property (nonatomic,strong) UIView* rightView;
@property (nonatomic,retain) UILabel *lableDate;


@end

@implementation ZHStatisticsThreeCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        [self addMyChildViews];
        
    }
    return self;
}


-(void)addMyChildViews
{
    
    UIImageView *bgImageView = [[UIImageView alloc]init];
    [bgImageView setMyFramewithX:0 andY:0 andWidth:78 andHeight:250];
    bgImageView.image = [UIImage imageNamed:@"clinic-form"];
    [self.contentView addSubview:bgImageView];
    
    
    self.leftView = [[UIView alloc]init];
    [self.leftView setMyFramewithX:9 andY:10 andWidth:20 andHeight:50];
    self.leftView.backgroundColor = BLUECOLOR;
    [self.contentView addSubview:self.leftView];
    
    self.centerView = [[UIView alloc]init];
    [self.centerView setMyFramewithX:29 andY:10 andWidth:20 andHeight:50];
    self.centerView.backgroundColor = ORANGECOLOR;
    [self.contentView addSubview:self.centerView];
    
    self.rightView = [[UIView alloc]init];
    [self.rightView setMyFramewithX:49 andY:10 andWidth:20 andHeight:50];
    self.rightView.backgroundColor = PINKCOLOR;
    [self.contentView addSubview:self.rightView];
    
    self.lableDate = [[UILabel alloc]init];
    self.lableDate.textColor = [UIColor whiteColor];
    [self.lableDate setMyFramewithX:0 andY:250 andWidth:78 andHeight:20];
    [self.contentView addSubview:self.lableDate];
    self.lableDate.textAlignment = NSTextAlignmentCenter;
    self.lableDate.font = [UIFont systemFontOfSize:13 * WIDPro -2];
    
    
    
   
}

-(void)setDataWithArray:(NSMutableArray *)array andIndex:(NSInteger)index
{
    ZHClinicAllData *model = array[index];
    
    self.lableDate.text = [NSString stringWithFormat:@"%@",[DataTool removeDateYear:model.dateTime]];
    
    CGFloat orangeHeight = model.orangeProportion * ALLHEIGHT;
    CGFloat pinkHeight = model.pinkProportion * ALLHEIGHT;
    CGFloat blueHeight = model.blueProportion * ALLHEIGHT;
    
   
   
    ZHSaveCommenMeg *meg =  [ZHSaveClickDate shareData].judgeModel;
    
    /*
     
     @property (nonatomic,assign) NSInteger patienterNumber;
     @property (nonatomic,assign) NSInteger appointmentNumber;
     @property (nonatomic,assign) NSInteger notArrive;
     
     */
    
    
    
    
    if(meg.max == 0)
    {
        blueHeight =   1.0 ;
        orangeHeight =  1.0 ;
        pinkHeight =   1.0;

    }
    
    else
    {
        blueHeight =   (CGFloat)(model.patienterNumber - model.appointmentNumber - model.notArrive )*ALLHEIGHT / meg.max ;
        orangeHeight =   (CGFloat)(model.appointmentNumber)*ALLHEIGHT / meg.max ;
        pinkHeight =   (CGFloat)(model.notArrive )*ALLHEIGHT / meg.max ;
        
    }
   
    
    
    self.leftView.height = ( blueHeight)*HEIPro;
    self.centerView.height = ( orangeHeight)*HEIPro;
    self.rightView.height =  ( pinkHeight) *HEIPro;
    
    
    self.leftView.y = (250 - blueHeight) *HEIPro;
    self.centerView.y = (250 - orangeHeight) * HEIPro;
    self.rightView.y =  (250 - pinkHeight) * HEIPro;

    
}


@end
